home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / chkfls12.zip / FORMATCH.H < prev    next >
C/C++ Source or Header  |  1992-08-14  |  2KB  |  68 lines

  1. /*
  2. **    formatch() proto/data types header file (for use with MicroS*t C7.00)
  3. **
  4. **    Otto Makela, Jyvaskyla, Finland, 1992
  5. **    Distributed under the GNU General Public Licence:
  6. **    see file COPYING for details
  7. */
  8.  
  9. int formatch(char *path, unsigned int attribute, int (*routine)());
  10.  
  11. #ifndef    _A_RDONLY
  12. #include    <dos.h>
  13. #endif
  14.  
  15. #include    <time.h>
  16. #include    <stdlib.h>
  17.  
  18. struct file_match    {
  19.     unsigned char attribute;    /* Found DOS attribute */
  20.     time_t filetime;        /* time() format time file last modified */
  21.     struct tm file_tm;        /* Same in struct tm form */
  22.     unsigned long filesize;        /* Length of file */
  23.     char filename[65];        /* Full filename, shortname ->here */
  24.     char *shortname;        /* Pointer to filename tail part */
  25.     char *extension;        /* Pointer to filename extension */
  26. };
  27.  
  28. /*
  29. **    These masks are identical to DOS file attribute bits
  30. */
  31. #define    READONLY    _A_RDONLY    /* DOS attribute 0x01 */
  32. #define    HIDDEN        _A_HIDDEN    /* DOS attribute 0x02 */
  33. #define    SYSTEM        _A_SYSTEM    /* DOS attribute 0x04 */
  34. #define    VOLABEL        _A_VOLID    /* DOS attribute 0x08 */
  35. #define    DIRECTORY    _A_SUBDIR    /* DOS attribute 0x10 */
  36. #define    ARCHIVE        _A_ARCH        /* DOS attribute 0x20 */
  37.  
  38. #define    ALLREALONES    (_A_NORMAL|_A_RDONLY|_A_HIDDEN|_A_SYSTEM\
  39.             |_A_VOLID|_A_SUBDIR|_A_ARCH)
  40.  
  41. /*
  42. **    These masks modify the functioning of formatch()
  43. */
  44. #define    DOTHIDDEN    0x0100        /* Treat . and .. as hidden files */
  45. #define    MATCHNONWILD    0x0200        /* Force match on nonwild files */
  46. #define    RECURSIVE    0x0400        /* Recurse subdirectories */
  47. #define    DIRFIRST    0x0800        /* Recursive: return directory first */
  48.  
  49. extern char switchar,dirsepar,othersepar;
  50.  
  51. /*
  52. **    The environment variable SWITCHAR is the switch character
  53. **    which this program uses.  If it is set to a slash, we will
  54. **    emulate the standard MS-DOS command line conventions,
  55. **    otherwise we try to be somewhat unix-like
  56. */
  57. #define    init_match()    \
  58.         do    {\
  59.             if(!switchar)    {\
  60.                 char *p;\
  61.                 if((p=getenv("SWITCHAR")) && (switchar=*p)=='/')    {\
  62.                     dirsepar='\\';\
  63.                     othersepar='/';\
  64.                 } else\
  65.                     switchar='-';\
  66.             }\
  67.         } while(0)
  68.